package com.etc.controller;

import com.etc.entity.*;
import com.etc.service.DeleteService;
import com.etc.service.InsertService;
import com.etc.service.UpdateService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@CrossOrigin
public class UpdateController {
    @Resource
    private UpdateService service;

    @Resource
    private DeleteService deleteService;

    @Resource
    private InsertService insertService;

    //修改楼栋信息
    @RequestMapping("consumer/building/update")
    public CommentResult updateBuilding(@RequestBody Building building)
    {
        return service.updateBuilding(building);
    }

    //修改房间信息
    @RequestMapping("consumer/room/update")
    public CommentResult updateRoom(@RequestBody Room room)
    {
        return service.updateRoom(room);
    }

    @RequestMapping("consumer/room/buyRoom/{owner_id}/{id}")
    public CommentResult buyRoom(@PathVariable("owner_id")Integer owner_id, @PathVariable("id")Integer id)
    {
        return service.buyRoom(owner_id,id);
    }

    @RequestMapping("consumer/room/sellRoom/{id}")
    public CommentResult sellRoom(@PathVariable("id")Integer id)
    {
        return service.sellRoom(id);
    }

    //修改小区信息
    @RequestMapping("consumer/park/update")
    public CommentResult updatePark(@RequestBody Park park)
    {
        return service.updatePark(park);
    }

    //修改业主信息
    @RequestMapping("consumer/owner/update")
    public CommentResult updateOwner(@RequestBody Owner owner)
    {
        return service.updateOwner(owner);
    }

    //修改公告信息
    @RequestMapping("consumer/infobar/update")
    public CommentResult updateInfobar(@RequestPart(value = "file",required = false) MultipartFile file,
                                       @RequestParam("id")Integer id,
                                       @RequestParam("info") String info,
                                       @RequestParam("park_id")Integer park_id,
                                       @RequestParam("upload_date")String upload_date)
    {


            return service.updateInfobar(file,id,info,park_id,upload_date);

    }

    //修改维修设备信息
    @RequestMapping("consumer/device/update")
    public CommentResult updateDevice(@RequestBody Device device)
    {
        return service.updateDevice(device);
    }

    //修改住户信息
    @RequestMapping("consumer/household/update")
    public CommentResult updateHousehold(@RequestBody Household household)
    {
        return service.updateHousehold(household);
    }

    //修改缴费信息
    @RequestMapping("consumer/payment/update")
    public CommentResult updatePayment(@RequestBody Payment payment)
    {
        return service.updatePayment(payment);
    }

    @RequestMapping("consumer/payment/changeStatus")
    public CommentResult changeStatus()
    {
        return service.changeStatus();
    }
}
